package com.lagou.rabbitmq.demo.dao;

import com.lagou.rabbitmq.demo.pojo.Order;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface OrderDao extends JpaRepository<Order,Long> {



  /*  @Modifying
    @Query(value = "update t_order SET  type =1 where order_no =:order_no ",nativeQuery = true)
    void updateStatusById(String order_no);*/

    @Transactional
    @Modifying//增删改必须有这个注解
    @Query(value = "update t_order set o_type =1  where order_no = :order_id ",nativeQuery = true)
    int updateStatusById(String order_id);

    @Query(value = "select id, order_no,o_type from t_order where order_no = :order_id ",nativeQuery = true)
    List<Order> queryByOrder_no(String order_id);

}
